<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="util.Time.TimeDifference" %><%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2024/4/10
  Time: 16:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" type="text/css" href="SystemTime.css" />
    <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
    <script src="SystemTime.js" type="text/javascript" ></script>
</head>
<body>
    <h1 class="box">
        <span class="system-Date"></span>&nbsp;&nbsp;&nbsp;
        <span class="system-time"></span>
    </h1>

    <h2 class="loginTime">
        <span>
            <%
                //这里的代码会被翻译到Servlet类体中，所以被当作全局变量处理
                //读取进入系统的时间
                String startTime= (String) session.getAttribute("loginStartTime");
                //获取系统当前时间
                String endTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(System.currentTimeMillis());
                //获取时间差值
                String differentTime = TimeDifference.getTimeDifference(endTime,startTime);
            %>
            在线时长：
            <%=differentTime%>
        </span>
        <span class="loginTime"></span>
    </h2>

</body>
</html>
